import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Enroll from '@/components/enroll/index.vue'
const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'enroll',
        component: Enroll,
    },
    {
        path: '/login',
        name: 'login',
        component: () => import("@/components/login/index.vue"),
    },
    {
        path:'/content',
        name:'content',
        component: () => import("@/view/content/index.vue"),
        beforeEnter: (to, from, next) => {
            if(localStorage.token){
                next()
            }else{
                next('/')
            }
            
        },
        // redirect:{name:'live'},
        children:[
            {
                path:'live',
                name:'live',
                component: () => import('@/view/content/live/index.vue'),
            },
            {
                path:'commend',
                name:'commend',
                component: () => import('@/view/content/commend/index.vue')
            },
            {
                path:'hot',
                name:'hot',
                component: () => import('@/view/content/hot/index.vue')
            },
            {
                path:'follow',
                name:'follow',
                component: () => import('@/view/content/follow/index.vue')
            },
            {
                path:'flim',
                name:'flim',
                component: () => import('@/view/content/flim/index.vue')
            },
            {
                path:'party',
                name:'party',
                component: () => import('@/view/content/party/index.vue')
            },
            {
                path:'home',
                name:'home',
                component: () => import('@/view/content/home/index.vue')
            },
            {
                path:'shop',
                name:'shop',
                component: () => import('@/view/content/shop/index.vue')
            },
            {
                path:'sow',
                name:'sow',
                component: () => import('@/view/content/sow/index.vue')
            },
            {
                path:'message',
                name:'message',
                component: () => import('@/view/content/message/index.vue')
            },
            {
                path:'seter',
                name:'seter',
                component: () => import('@/view/content/seter/index.vue')
            }
        ]
        
    }
    
]

// 创建
const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router